package edu.scu.declaresys.dao.intr;

import org.hibernate.Session;
import org.hibernate.criterion.SimpleExpression;

import edu.scu.declaresys.exception.ExecuteException;
import edu.scu.declaresys.util.PageList;

/**
 * 
 * @author: zt
 * @since : 2013-7-2
 */
public interface IGeneralDAO<T>
{
	public Session getSession();
	
	public void closeSession();
	//
	// read methods.
	//
	public T findById(Integer id, int depth) throws ExecuteException;	
	
	public T findByPropertyUnique(String propertyName, Object value, int depth) throws ExecuteException;
	
	public T findByExampleUnique(T vo, int depth) throws ExecuteException;
	
	public PageList<T> findByExample(T vo, int depth, Integer pageNum, Integer amtPerPage, String orderColumn, Boolean isAsc) throws ExecuteException;
	
	public PageList<T> findByProperty(String propertyName, Object value, int depth, Integer pageNum, Integer amtPerPage, String orderColumn, Boolean isAsc) throws ExecuteException;
	
	/**
	 * 
	 *@param propertyName
	 *@param value
	 *@param orderColumn
	 *@param isAsc
	 *@return
	 *@throws ExecuteException
	 */
	public PageList<T> findByStringLike(String propertyName, String value, int depth, Integer pageNum, Integer amtPerPage, String orderColumn, Boolean isAsc) throws ExecuteException;	
	//
	// write methods.
	//
	public Integer save(T vo) throws ExecuteException;
	
	public void update(T vo, Integer id) throws ExecuteException;
	
	public void delete(int id) throws ExecuteException;

	PageList<T> findByProperty(SimpleExpression exp, int depth,
			Integer pageNum, Integer amtPerPage, String orderColumn,
			Boolean isAsc) throws ExecuteException;
}
